home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / wgdb-42.lha / wgdb-4.2 / gdb / xm-altos.h < prev    next >
C/C++ Source or Header  |  1992-09-11  |  6KB  |  209 lines

  1. /* Definitions to make GDB run on an Altos 3068 (m68k running SVR2)
  2.    Copyright (C) 1987,1989 Free Software Foundation, Inc.
  3.  
  4. This file is part of GDB.
  5.  
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #define HOST_BYTE_ORDER BIG_ENDIAN
  21.  
  22. /* The altos support would make a good base for a port to other USGR2 systems
  23.    (like the 3b1 and the Convergent miniframe).  */
  24.  
  25. /* This is only needed in one file, but it's cleaner to put it here than
  26.    putting in more #ifdef's.  */
  27. #include <sys/page.h>
  28. #include <sys/net.h>
  29.  
  30. #define USG
  31.  
  32. #define HAVE_TERMIO
  33.  
  34. #define CBREAK XTABS    /* It takes all kinds... */
  35.  
  36. #ifndef R_OK
  37. #define R_OK 4
  38. #define W_OK 2
  39. #define X_OK 1
  40. #define F_OK 0
  41. #endif
  42.  
  43. #ifndef MAXPATHLEN
  44. #define MAXPATHLEN (1024)
  45. #endif
  46.  
  47. /* Get sys/wait.h ie. from a Sun and edit it a little (mc68000 to m68k) */
  48. /* Why bother?  */
  49. #if 0
  50. #define HAVE_WAIT_STRUCT
  51. #endif
  52.  
  53. #define vfork fork
  54.  
  55. /* This is the amount to subtract from u.u_ar0
  56.    to get the offset in the core file of the register values. */
  57.  
  58. #define KERNEL_U_ADDR 0x1fbf000
  59.  
  60. #define REGISTER_U_ADDR(addr, blockend, regno)        \
  61. {    if (regno <= SP_REGNUM) \
  62.       addr = blockend + regno * 4; \
  63.     else if (regno == PS_REGNUM) \
  64.       addr = blockend + regno * 4 + 4; \
  65.     else if (regno == PC_REGNUM) \
  66.       addr = blockend + regno * 4 + 2; \
  67. }
  68.  
  69. #define REGISTER_ADDR(u_ar0, regno)                    \
  70.   (((regno) < PS_REGNUM)                        \
  71.    ? (&((struct exception_stack *) (u_ar0))->e_regs[(regno + R0)])    \
  72.    : (((regno) == PS_REGNUM)                        \
  73.       ? ((int *) (&((struct exception_stack *) (u_ar0))->e_PS))        \
  74.       : (&((struct exception_stack *) (u_ar0))->e_PC)))
  75.  
  76. #define FP_REGISTER_ADDR(u, regno)                    \
  77.   (((char *)                                \
  78.     (((regno) < FPC_REGNUM)                        \
  79.      ? (&u.u_pcb.pcb_mc68881[FMC68881_R0 + (((regno) - FP0_REGNUM) * 3)]) \
  80.      : (&u.u_pcb.pcb_mc68881[FMC68881_C + ((regno) - FPC_REGNUM)])))    \
  81.    - ((char *) (& u)))
  82.  
  83.  
  84. #ifndef __GNUC__
  85. #undef USE_GAS
  86. #define ALTOS_AS
  87. #else
  88. #define USE_GAS
  89. #endif
  90.  
  91. /* Motorola assembly format */
  92. #if !defined(USE_GAS) && !defined(ALTOS)
  93. #define MOTOROLA
  94. #endif
  95.  
  96. /* Interface definitions for kernel debugger KDB.  */
  97.  
  98. /* Map machine fault codes into signal numbers.
  99.    First subtract 0, divide by 4, then index in a table.
  100.    Faults for which the entry in this table is 0
  101.    are not handled by KDB; the program's own trap handler
  102.    gets to handle then.  */
  103.  
  104. #define FAULT_CODE_ORIGIN 0
  105. #define FAULT_CODE_UNITS 4
  106. #define FAULT_TABLE    \
  107. { 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \
  108.   0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \
  109.   0, 0, 0, 0, 0, 0, 0, 0, \
  110.   SIGILL }
  111.  
  112. /* Start running with a stack stretching from BEG to END.
  113.    BEG and END should be symbols meaningful to the assembler.
  114.    This is used only for kdb.  */
  115.  
  116. #ifdef MOTOROLA
  117. #define INIT_STACK(beg, end)  \
  118. { asm (".globl end");         \
  119.   asm ("move.l $ end, sp");      \
  120.   asm ("clr.l fp"); }
  121. #else
  122. #ifdef ALTOS_AS
  123. #define INIT_STACK(beg, end)  \
  124. { asm ("global end");         \
  125.   asm ("mov.l &end,%sp");      \
  126.   asm ("clr.l %fp"); }
  127. #else
  128. #define INIT_STACK(beg, end)  \
  129. { asm (".globl end");         \
  130.   asm ("movel $ end, sp");      \
  131.   asm ("clrl fp"); }
  132. #endif
  133. #endif
  134.  
  135. /* Push the frame pointer register on the stack.  */
  136. #ifdef MOTOROLA
  137. #define PUSH_FRAME_PTR        \
  138.   asm ("move.l fp, -(sp)");
  139. #else
  140. #ifdef ALTOS_AS
  141. #define PUSH_FRAME_PTR        \
  142.   asm ("mov.l %fp, -(%sp)");
  143. #else
  144. #define PUSH_FRAME_PTR        \
  145.   asm ("movel fp, -(sp)");
  146. #endif
  147. #endif
  148.  
  149. /* Copy the top-of-stack to the frame pointer register.  */
  150. #ifdef MOTOROLA
  151. #define POP_FRAME_PTR  \
  152.   asm ("move.l (sp), fp");
  153. #else
  154. #ifdef ALTOS_AS
  155. #define POP_FRAME_PTR  \
  156.   asm ("mov.l (%sp), %fp");
  157. #else
  158. #define POP_FRAME_PTR  \
  159.   asm ("movl (sp), fp");
  160. #endif
  161. #endif
  162.  
  163. /* After KDB is entered by a fault, push all registers
  164.    that GDB thinks about (all NUM_REGS of them),
  165.    so that they appear in order of ascending GDB register number.
  166.    The fault code will be on the stack beyond the last register.  */
  167.  
  168. #ifdef MOTOROLA
  169. #define PUSH_REGISTERS        \
  170. { asm ("clr.w -(sp)");          \
  171.   asm ("pea (10,sp)");          \
  172.   asm ("movem $ 0xfffe,-(sp)"); }
  173. #else
  174. #ifdef ALTOS_AS
  175. #define PUSH_REGISTERS        \
  176. { asm ("clr.w -(%sp)");          \
  177.   asm ("pea (10,%sp)");          \
  178.   asm ("movm.l &0xfffe,-(%sp)"); }
  179. #else
  180. #define PUSH_REGISTERS        \
  181. { asm ("clrw -(sp)");          \
  182.   asm ("pea 10(sp)");          \
  183.   asm ("movem $ 0xfffe,-(sp)"); }
  184. #endif
  185. #endif
  186.  
  187. /* Assuming the registers (including processor status) have been
  188.    pushed on the stack in order of ascending GDB register number,
  189.    restore them and return to the address in the saved PC register.  */
  190.  
  191. #ifdef MOTOROLA
  192. #define POP_REGISTERS          \
  193. { asm ("subi.l $8,28(sp)");     \
  194.   asm ("movem (sp),$ 0xffff"); \
  195.   asm ("rte"); }
  196. #else
  197. #ifdef ALTOS_AS
  198. #define POP_REGISTERS          \
  199. { asm ("sub.l &8,28(%sp)");     \
  200.   asm ("movem (%sp),&0xffff"); \
  201.   asm ("rte"); }
  202. #else
  203. #define POP_REGISTERS          \
  204. { asm ("subil $8,28(sp)");     \
  205.   asm ("movem (sp),$ 0xffff"); \
  206.   asm ("rte"); }
  207. #endif
  208. #endif
  209.